<?php
namespace Admin\Controller;
use Think\Controller;
class SysController extends Controller {
    public function index(){
    	$model=M("lunbo");
    	$this->data=$model->select();
    	$this->display();
    }
    public function upload(){
     if (!empty($_FILES)) {
            //图片上传设置
           $upload = new \Think\Upload();// 实例化上传类
			$upload->maxSize   =     3145728 ;// 设置附件上传大小
			$upload->exts      =     array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
			$upload->savePath  =      '/lunbo/'; // 设置附件上传目录// 上传文件 
            $images = $upload->upload();
            //判断是否有图
            if($images){
                $info=$images['Filedata']['savepath'].$images['Filedata']['savename'];
                //返回文件地址和名给JS作回调用
                echo $info;
            }
            else{
                $this->error($upload->getError());//获取失败信息
            }
        }
    }
    public function savelb(){
    	$model=M("lunbo");
    	$data["lb_url"]=$_POST['lb_url'];
    	$data["lb_name"]=$_POST['lb_name'];
    	$data["lb_order"]=0;
    	$res=$model->add($data);
    	if($res){
    		echo "1";
    	}else{
    		echo "0";
    	}
    }
}